package cn.cs.controller;

import cn.cs.common.*;
import cn.cs.config.AgentConfig;
import cn.cs.config.AlipayConfig;
import cn.cs.config.WXPayConfig;
import cn.cs.pojo.*;
import cn.cs.service.QgWxpayService;
import cn.cs.service.WithdrawalPayService;
import cn.cs.util.GetWxOrderno;
import cn.cs.util.RequestHandler;
import cn.cs.util.WXPayUtil;
import com.alibaba.fastjson.JSON;
import com.alipay.api.AlipayClient;
import com.alipay.api.DefaultAlipayClient;
import com.alipay.api.request.AlipayFundTransToaccountTransferRequest;
import com.alipay.api.response.AlipayFundTransToaccountTransferResponse;
import org.apache.log4j.Logger;
import org.springframework.stereotype.Controller;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.*;

@Controller
@RequestMapping(value = "/withdrawalPay")
public class WithdrawalPayController {

    private Logger logger = Logger.getLogger(WithdrawalPayController.class);
    @Resource
    private WithdrawalPayService withdrawalPayService;
    @Resource
    private AlipayConfig alipayConfig;
    @Resource
    private WXPayConfig wxPayConfig;
    @Resource
    private AgentConfig agentConfig;

    @Resource
    private QgWxpayService qgWxpayService;


    @RequestMapping("/csPlatform/dealerSettlement")
    @Transactional
    public String dealerSettlement(@RequestBody SettlementDetailed settlementDetailed)throws Exception {
        Map<String, Object> policy = withdrawalPayService.getSetPolicyByType("2");
        int polCycle = Integer.valueOf(policy.get("pol_date").toString());

       /**
        * 月结算
       * */
       int newDate = Integer.valueOf(DateUtil.format(new Date(), "d"));
        System.out.println(newDate);
        if(polCycle == newDate){
            String agentId = settlementDetailed.getAgentId();
            Agent agent = withdrawalPayService.getAgentById(agentId);
            if(agent != null){
                String openId = agent.getOpenid();
                String alipayUserid = agent.getAlipayUserid();
                if(EmptyUtils.isNotEmpty(openId) || EmptyUtils.isNotEmpty(alipayUserid)){
                    String id = IdWorker.getId();
                    settlementDetailed.setId(id);
                    settlementDetailed.setSetTime(DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss"));
                    settlementDetailed.setSetState("0");
                    settlementDetailed.setOpenid(openId);
                    settlementDetailed.setAlipayUserid(alipayUserid);

                    String[] orderIds = settlementDetailed.getIds().split(",");
                    List<Map<String, String>> list = new ArrayList<>();
                    for(String a:orderIds){
                        Map<String, String> map = new HashMap<>();
                        map.put("id", IdWorker.getId());
                        map.put("set_id", id);
                        map.put("rep_order_id", a);
                        list.add(map);
                    }
                    CsProportionSetting setting = withdrawalPayService.getProportionSetting();
                    Double capital_pool = Double.valueOf(setting.getCapitalPool());
                    Double money = Double.valueOf(settlementDetailed.getSetMoney());
//                    settlementDetailed.setSetMoney(String.valueOf(new BigDecimal(money * (1-capital_pool)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue()));


                    CapitalPoolDetails capitalPoolDetails = new CapitalPoolDetails();
                    capitalPoolDetails.setTitle("资金池入账");
                    capitalPoolDetails.setContent("资金池入账");
                    capitalPoolDetails.setAgentId(settlementDetailed.getAgentId());
                    capitalPoolDetails.setType("1");
                    capitalPoolDetails.setMoney(new BigDecimal(money * capital_pool).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());

                    settlementDetailed.setCapital_pool_money(capitalPoolDetails.getMoney().toString());

                    withdrawalPayService.dealerSettlement(list, settlementDetailed, capitalPoolDetails);

                    return "forward:/cs_pay/withdrawalPay/handleWithdrawal?id="+id+"&userType=2&username="+settlementDetailed.getUsername()+"&agentType="+ agent.getTypeId();
                }
            }
            return "forward:/cs_pay/withdrawalPay/returnDealerFail?msg=经销商未绑定支付宝微信，无法转账&code=001";
        }
        return "forward:/cs_pay/withdrawalPay/returnDealerFail?msg=未到结算日期，无法结算&code=002";

    }







    /**
     * 处理提现申请（转账）
     * @param userType 分类 1维修工提现 2经销商维修单提成收益提现 3经销商商城收益提现
     */
    @RequestMapping(value = "/csPlatform/handleWithdrawalBatch")
    @ResponseBody
    @Transactional
    public Dto handleWithdrawalBatch(String ids, String userType, String username) throws Exception{
        String _ids[] = ids.split(",");
        int i = _ids.length;
        int j = 0;
        for(String id:_ids){
            if(EmptyUtils.isNotEmpty(id)){
                Dto dto = handleWithdrawalOperation(id, userType, username, "");
                if("true".equals(dto.getSuccess())){
                    j ++;
                }
            }
        }
        if(i == j){
            return DtoUtil.returnSuccess("操作成功", "");
        }
        return DtoUtil.returnFail("转账操作未全部成功，可单个转账查看失败原因", "");
    }



    /**
     * 处理提现申请（转账）经销商转账 -- 单个
     * @param id
     * @param username
     * @return
     * @throws Exception
     */
    @RequestMapping(value = "/csPlatform/agentHhandleWithdrawal")
    @ResponseBody
    public Dto agentHhandleWithdrawal(String id, String username) throws Exception{
        return withdrawalPayService.agentHhandleWithdrawal(id, username);
    }

    /**
     * 处理提现申请（转账）经销商批量处理转账
     * @param ids
     * @param username
     * @return
     * @throws Exception
     */
    @RequestMapping(value = "/csPlatform/agentHhandleWithdrawalBatch")
    @ResponseBody
    public Dto agentHhandleWithdrawalBatch(String ids, String username) throws Exception{
        return withdrawalPayService.agentHhandleWithdrawalBatch(ids, username);
    }





    /**
     * 处理提现申请（转账）
     * @param id 提现记录Id
     * @param userType 分类 1维修工提现 2经销商维修单提成收益提现 3经销商商城收益提现
     */
    @RequestMapping(value = "/csPlatform/handleWithdrawal")
    @ResponseBody
    @Transactional
    public Dto handleWithdrawal(String id, String userType, String username, String agentType) throws Exception{
        return handleWithdrawalOperation(id, userType, username, agentType);
    }


    public Dto handleWithdrawalOperation(String id, String userType, String username, String agentType) throws Exception{
        CsPerson person = withdrawalPayService.findPersonByName(username);
        if(EmptyUtils.isNotEmpty(person.getId())){
            userType = EmptyUtils.isEmpty(userType)?"1":userType;
            Map<String, String> map = null;
            String money = "";
            if("1".equals(userType)){
                map = withdrawalPayService.handleWithdrawalRepairUser(id);
                money = map.get("money");
            }else if("2".equals(userType)){
                map = withdrawalPayService.handleWithdrawalAgent(id);
                String rep_order_id = map.get("rep_order_id");
                if("1".equals(agentType)){
                    int i = withdrawalPayService.updateOrderStateAAgent(rep_order_id);
                    logger.info("info---------------------------------------------------------AAAAAAA：" + i);
                }else{
                    int i = withdrawalPayService.updateOrderStateBAgent(rep_order_id);
                    logger.info("info---------------------------------------------------------BBBBBB：" + i);
                }
                money = map.get("money");
                Double capital_pool_money = Double.valueOf(map.get("capital_pool_money").toString());
                money = String.valueOf(new BigDecimal(Double.valueOf(money) - capital_pool_money).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());

            }else{
                map = withdrawalPayService.handleWithdrawalAgentShop(id);
                CsProportionSetting setting = withdrawalPayService.getProportionSetting();
                String product_service_charge = setting.getProductServiceCharge();
                Double _money = Double.valueOf(map.get("money")) * (1 - Double.valueOf(product_service_charge));
                money = String.valueOf(new BigDecimal(_money).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
            }
            if(map == null){
                return DtoUtil.returnFail("此申请不存在或者已处理过，请勿处理","001");
            }
            String transactionId = "";

            String type = map.get("type");
            if("1".equals(type)){//微信
                Map<String, String> m = new HashMap<>();
                m.put("openid",map.get("openid"));
                m.put("orderId",id);
                m.put("money",money);
                m.put("spbillCreateIp","127.0.0.1");

                //暂时屏蔽付款
                Map<String, Object> responseMap = null;
                if("1".equals(userType)){
                    responseMap = sendPayWXG(m);
                }else{
                    responseMap = sendPay(m);
                }
                if(responseMap != null && responseMap.size() > 0){
                    if("SUCCESS".equals(responseMap.get("result_code").toString())){
                        transactionId = responseMap.get("partner_trade_no").toString();
                        qgWxpayService.insertTrade(id, transactionId, map.get("userId"), money, "0");
                        System.out.println("调用成功");
                        withdrawalPayService.updateState(id, person.getId());
                        return DtoUtil.returnSuccess("操作成功","");
                    }else{
                        String err_code = responseMap.get("err_code").toString();
                        String msg = "操作失败";
                        switch (err_code){
                            case "AMOUNT_LIMIT":msg += ",金额超限!";break;
                            case "NOTENOUGH":msg += ",您的付款帐号余额不足或资金未到账!";break;
                            case "SYSTEMERROR":msg += ",系统繁忙，请稍后再试!";break;
                            case "V2_ACCOUNT_SIMPLE_BAN":msg += ",用户微信支付账户未知名，无法付款!";break;
                            case "SENDNUM_LIMIT":msg += ",该用户今日付款次数超过限制,如有需要请登录微信支付商户平台更改API安全配置!";break;
                            case "MONEY_LIMIT":msg += ",已经达到今日付款总额上限/已达到付款给此用户额度上限!";break;
                            case "FREQ_LIMIT":msg += ",超过频率限制，请稍后再试!";break;
                            default:break;
                        }
                        return DtoUtil.returnFail(msg, err_code);
                    }
                }
                return DtoUtil.returnFail("操作失败，请重试","003");
            }else{//支付宝
                AlipayClient alipayClient = new DefaultAlipayClient("https://openapi.alipay.com/gateway.do",alipayConfig.getTransferAppID(),alipayConfig.getTransferPrivateKey(),"json","UTF-8",alipayConfig.getTransferAlipayPublicKey(),"RSA2");
                AlipayFundTransToaccountTransferRequest request = new AlipayFundTransToaccountTransferRequest();
                request.setBizContent("{" +
                        "\"out_biz_no\":\""+id+"\"," +
                        //收款方账户类型。可取值：
                        //1、ALIPAY_USERID：支付宝账号对应的支付宝唯一用户号。以2088开头的16位纯数字组成。
                        //2、ALIPAY_LOGONID：支付宝登录号，支持邮箱和手机号格式。
//                    "\"payee_type\":\"ALIPAY_LOGONID\"," +
                        "\"payee_type\":\"ALIPAY_USERID\"," +
                        "\"payee_account\":\""+map.get("alipay_userid")+"\"," +
                        "\"amount\":\""+money+"\"," +
//                    "\"payer_show_name\":\"提现成功\"," +
//                    "\"payee_real_name\":\"张三\"," +
//                    "\"remark\":\"转账备注\"" +
                        "  }");

                //暂时屏蔽支付
                AlipayFundTransToaccountTransferResponse response = alipayClient.execute(request);
                if(response.isSuccess()){
                    System.out.println("调用成功");
                    logger.info("info---------------------------------------------------------支付宝支付成功response：" + JSON.toJSON(response));
                    transactionId = response.getOrderId();
                    withdrawalPayService.updateState(id, person.getId());
                    qgWxpayService.insertTrade(id, transactionId, map.get("userId"), money, "0");
                    return DtoUtil.returnSuccess("操作成功","");
                } else {
                    System.out.println("调用失败");
                    System.out.println(JSON.toJSON(response));
                    logger.info("info---------------------------------------------------------支付宝支付失败response：" + JSON.toJSON(response));
                    return DtoUtil.returnFail("操作失败," + response.getSubMsg(),response.getSubCode());
                }

            }
        }
        return DtoUtil.returnFail("操作失败，操作人不存在","004");
    }



    /**
     * 经销商提现
     * @param m
     * @return
     * @throws Exception
     */
    public Map<String, Object> sendPay(Map<String, String> m)throws Exception {

        String openId = m.get("openid");
        // 1 参数
        // 订单号
        String orderId = m.get("orderId");
        // 总金额以分为单位，不带小数点
        String totalFee = WXPayUtil.getMoney(m.get("money"));

        // 订单生成的机器 IP
        String spbill_create_ip = m.get("spbillCreateIp");

        // ---必须参数
        // 商户号
        String mch_id = wxPayConfig.getMchID();
        // 随机字符串
        String nonce_str = WXPayUtil.getNonceStr();


        SortedMap<String, String> packageParams = new TreeMap<String, String>();
        packageParams.put("mch_appid", wxPayConfig.getJxsAppId());
        packageParams.put("mchid", mch_id);
        packageParams.put("nonce_str", nonce_str);
        packageParams.put("desc", "管理商收益");
        packageParams.put("partner_trade_no", orderId);
        // 这里写的金额为1 分到时修改
        packageParams.put("amount", totalFee);
        packageParams.put("spbill_create_ip", spbill_create_ip);
        packageParams.put("check_name", "NO_CHECK");
        packageParams.put("openid", openId);

        RequestHandler reqHandler = new RequestHandler(null, null);
        reqHandler.init(wxPayConfig.getJxsAppId(), wxPayConfig.getJxsSecret(), wxPayConfig.getKey());

        String sign = reqHandler.createSign(packageParams);
        logger.info("第一次签名------------------------------" + sign);
        System.out.println("第一次签名------------------------------" + sign);
        String xml = "<xml>" + "<mch_appid>" + wxPayConfig.getJxsAppId() + "</mch_appid>" + "<mchid>"
                + mch_id + "</mchid>" + "<nonce_str>" + nonce_str
                + "</nonce_str>"
                + "<partner_trade_no>" + orderId + "</partner_trade_no>"
                + "<openid>" + openId + "</openid>"
                + "<check_name>NO_CHECK</check_name>"
                + "<amount>" + totalFee + "</amount>"
                + "<desc>管理商收益</desc>"
                + "<spbill_create_ip>" + spbill_create_ip + "</spbill_create_ip>"
                + "<sign>" + sign + "</sign>"
                + "</xml>";
        String createOrderURL = "https://api.mch.weixin.qq.com/mmpaymkttransfers/promotion/transfers";


        Map<String, Object> map = new GetWxOrderno().sendPost(createOrderURL, xml);
        logger.info("info---------------------------------------------------------获取到的预支付ID：" + map);
        System.out.println("获取到的预支付ID：" + map);

        return map;
    }

    /**
     * 维修工申请提现
     * @param m
     * @return
     * @throws Exception
     */
    public Map<String, Object> sendPayWXG(Map<String, String> m)throws Exception {

        String openId = m.get("openid");
        // 1 参数
        // 订单号
        String orderId = m.get("orderId");
        // 总金额以分为单位，不带小数点
        String totalFee = WXPayUtil.getMoney(m.get("money"));

        // 订单生成的机器 IP
        String spbill_create_ip = m.get("spbillCreateIp");

        // ---必须参数
        // 商户号
        String mch_id = wxPayConfig.getMchID();
        // 随机字符串
        String nonce_str = WXPayUtil.getNonceStr();


        SortedMap<String, String> packageParams = new TreeMap<String, String>();
        packageParams.put("mch_appid", wxPayConfig.getPayAppId());
        packageParams.put("mchid", mch_id);
        packageParams.put("nonce_str", nonce_str);
        packageParams.put("desc", "维修师傅收益");
        packageParams.put("partner_trade_no", orderId);
        // 这里写的金额为1 分到时修改
        packageParams.put("amount", totalFee);
        packageParams.put("spbill_create_ip", spbill_create_ip);
        packageParams.put("check_name", "NO_CHECK");
        packageParams.put("openid", openId);

        RequestHandler reqHandler = new RequestHandler(null, null);
        reqHandler.init(wxPayConfig.getPayAppId(), wxPayConfig.getPayAppSecret(), wxPayConfig.getKey());

        String sign = reqHandler.createSign(packageParams);
        logger.info("第一次签名------------------------------" + sign);
        System.out.println("第一次签名------------------------------" + sign);
        String xml = "<xml>" + "<mch_appid>" + wxPayConfig.getPayAppId() + "</mch_appid>" + "<mchid>"
                + mch_id + "</mchid>" + "<nonce_str>" + nonce_str
                + "</nonce_str>"
                + "<partner_trade_no>" + orderId + "</partner_trade_no>"
                + "<openid>" + openId + "</openid>"
                + "<check_name>NO_CHECK</check_name>"
                + "<amount>" + totalFee + "</amount>"
                + "<desc>维修师傅收益</desc>"
                + "<spbill_create_ip>" + spbill_create_ip + "</spbill_create_ip>"
                + "<sign>" + sign + "</sign>"
                + "</xml>";
        String createOrderURL = "https://api.mch.weixin.qq.com/mmpaymkttransfers/promotion/transfers";


        Map<String, Object> map = new GetWxOrderno().sendPost(createOrderURL, xml);
        logger.info("info---------------------------------------------------------获取到的预支付ID：" + map);
        System.out.println("获取到的预支付ID：" + map);

        return map;
    }

    /**
     * 经销商维修单提成收益提现  操作出错
     */
    @RequestMapping(value = "/returnDealerFail")
    @ResponseBody
    public Dto returnDealerFail(String msg, String code){
        return DtoUtil.returnFail(msg, code);
    }



    /**
     * 获取B级经销商支付的费用
     * @return
     */
    @RequestMapping(value = "/csPlatform/getAgentPayMoney")
    @ResponseBody
    public Dto getAgentPayMoney(){
        List<Object> list = new ArrayList<>();
        list.add(agentConfig);
        return DtoUtil.returnSuccess("获取成功！", list);
    }

    /**
     * 修改B级经销商支付的费用
     * @return
     */
    @RequestMapping(value = "/csPlatform/setAgentPayMoney")
    @ResponseBody
    public Dto setAgentPayMoney(String province, String city, String area){
        agentConfig.setProvince(province);
        agentConfig.setCity(city);
        agentConfig.setArea(area);
        return DtoUtil.returnSuccess("操作成功！", agentConfig);
    }

    /**
     * 账户初始化
     * @param money
     * @param type 分类 (1:支付宝 2:微信)
     * @return
     * @throws Exception
     */
    @RequestMapping(value = "/updateMoneyByType")
    @ResponseBody
    public Dto updateMoneyByType(String money, String type)throws Exception{
        Map<String, Object> map = qgWxpayService.getFundsAccountByType(type);
        if("0".equals(map.get("initialization").toString())){
            return DtoUtil.returnSuccess("初始化成功", qgWxpayService.updateMoneyByType(money, type));
        }
        return DtoUtil.returnFail("已初始化过，无法再次初始化", "001");
    }

    /**
     * 获取资金商户
     * @param type 分类 (1:支付宝 2:微信)
     * @return
     * @throws Exception
     */
    @RequestMapping(value = "/getFundsAccountByType")
    @ResponseBody
    public Dto getFundsAccountByType(String type)throws Exception{
        return DtoUtil.returnSuccess("获取成功", qgWxpayService.getFundsAccountByType(type));
    }

    /**
     * 获取每月结转金额
     * @param type 分类 (1:支付宝 2:微信)
     * @return
     * @throws Exception
     */
    @RequestMapping(value = "/getFundsCarryOverByType")
    @ResponseBody
    public Dto getFundsCarryOverByType(String type)throws Exception{
        return DtoUtil.returnSuccess("获取成功", qgWxpayService.getFundsCarryOverByType(type));
    }



    public Dto refundMoney(String id, String userType, String username, String agentType) throws Exception{
        CsPerson person = withdrawalPayService.findPersonByName(username);
        if(EmptyUtils.isNotEmpty(person.getId())){
            userType = EmptyUtils.isEmpty(userType)?"1":userType;
            Map<String, String> map = null;
            String money = "";
            if("1".equals(userType)){
                map = withdrawalPayService.handleWithdrawalRepairUser(id);
                money = map.get("money");
            }else if("2".equals(userType)){
                map = withdrawalPayService.handleWithdrawalAgent(id);
                String rep_order_id = map.get("rep_order_id");
                if("1".equals(agentType)){
                    int i = withdrawalPayService.updateOrderStateAAgent(rep_order_id);
                    logger.info("info---------------------------------------------------------AAAAAAA：" + i);
                }else{
                    int i = withdrawalPayService.updateOrderStateBAgent(rep_order_id);
                    logger.info("info---------------------------------------------------------BBBBBB：" + i);
                }
                money = map.get("money");
                Double capital_pool_money = Double.valueOf(map.get("capital_pool_money").toString());
                money = String.valueOf(new BigDecimal(Double.valueOf(money) - capital_pool_money).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());

            }else{
                map = withdrawalPayService.handleWithdrawalAgentShop(id);
                CsProportionSetting setting = withdrawalPayService.getProportionSetting();
                String product_service_charge = setting.getProductServiceCharge();
                Double _money = Double.valueOf(map.get("money")) * (1 - Double.valueOf(product_service_charge));
                money = String.valueOf(new BigDecimal(_money).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
            }
            if(map == null){
                return DtoUtil.returnFail("此申请不存在或者已处理过，请勿处理","001");
            }
            String transactionId = "";

            String type = map.get("type");
            if("1".equals(type)){//微信
                Map<String, String> m = new HashMap<>();
                m.put("openid",map.get("openid"));
                m.put("orderId",id);
                m.put("money",money);
                m.put("spbillCreateIp","127.0.0.1");

                //暂时屏蔽付款
                Map<String, Object> responseMap = null;
                if("1".equals(userType)){
                    responseMap = sendPayWXG(m);
                }else{
                    responseMap = sendPay(m);
                }
                if(responseMap != null && responseMap.size() > 0){
                    if("SUCCESS".equals(responseMap.get("result_code").toString())){
                        transactionId = responseMap.get("partner_trade_no").toString();
                        qgWxpayService.insertTrade(id, transactionId, map.get("userId"), money, "0");
                        System.out.println("调用成功");
                        withdrawalPayService.updateState(id, person.getId());
                        return DtoUtil.returnSuccess("操作成功","");
                    }else{
                        String err_code = responseMap.get("err_code").toString();
                        String msg = "操作失败";
                        switch (err_code){
                            case "AMOUNT_LIMIT":msg += ",金额超限!";break;
                            case "NOTENOUGH":msg += ",您的付款帐号余额不足或资金未到账!";break;
                            case "SYSTEMERROR":msg += ",系统繁忙，请稍后再试!";break;
                            case "V2_ACCOUNT_SIMPLE_BAN":msg += ",用户微信支付账户未知名，无法付款!";break;
                            case "SENDNUM_LIMIT":msg += ",该用户今日付款次数超过限制,如有需要请登录微信支付商户平台更改API安全配置!";break;
                            case "MONEY_LIMIT":msg += ",已经达到今日付款总额上限/已达到付款给此用户额度上限!";break;
                            case "FREQ_LIMIT":msg += ",超过频率限制，请稍后再试!";break;
                            default:break;
                        }
                        return DtoUtil.returnFail(msg, err_code);
                    }
                }
                return DtoUtil.returnFail("操作失败，请重试","003");
            }else{//支付宝
                AlipayClient alipayClient = new DefaultAlipayClient("https://openapi.alipay.com/gateway.do",alipayConfig.getTransferAppID(),alipayConfig.getTransferPrivateKey(),"json","UTF-8",alipayConfig.getTransferAlipayPublicKey(),"RSA2");
                AlipayFundTransToaccountTransferRequest request = new AlipayFundTransToaccountTransferRequest();
                request.setBizContent("{" +
                        "\"out_biz_no\":\""+id+"\"," +
                        //收款方账户类型。可取值：
                        //1、ALIPAY_USERID：支付宝账号对应的支付宝唯一用户号。以2088开头的16位纯数字组成。
                        //2、ALIPAY_LOGONID：支付宝登录号，支持邮箱和手机号格式。
//                    "\"payee_type\":\"ALIPAY_LOGONID\"," +
                        "\"payee_type\":\"ALIPAY_USERID\"," +
                        "\"payee_account\":\""+map.get("alipay_userid")+"\"," +
                        "\"amount\":\""+money+"\"," +
//                    "\"payer_show_name\":\"提现成功\"," +
//                    "\"payee_real_name\":\"张三\"," +
//                    "\"remark\":\"转账备注\"" +
                        "  }");

                //暂时屏蔽支付
                AlipayFundTransToaccountTransferResponse response = alipayClient.execute(request);
                if(response.isSuccess()){
                    System.out.println("调用成功");
                    logger.info("info---------------------------------------------------------支付宝支付成功response：" + JSON.toJSON(response));
                    transactionId = response.getOrderId();
                    withdrawalPayService.updateState(id, person.getId());
                    qgWxpayService.insertTrade(id, transactionId, map.get("userId"), money, "0");
                    return DtoUtil.returnSuccess("操作成功","");
                } else {
                    System.out.println("调用失败");
                    System.out.println(JSON.toJSON(response));
                    logger.info("info---------------------------------------------------------支付宝支付失败response：" + JSON.toJSON(response));
                    return DtoUtil.returnFail("操作失败," + response.getSubMsg(),response.getSubCode());
                }

            }
        }
        return DtoUtil.returnFail("操作失败，操作人不存在","004");
    }

}
